﻿using System.Text;
using System.Security.Cryptography;

namespace RSTAi.Platform.GrpcService.Common
{
    /// <summary>
    /// MD5
    /// </summary>
    public class MD5Helper
    {
        public static string Md5Key = "SRTAI_PLATFORM";
        public static string GetMD5(string input) {

            byte[] inputBytes = Encoding.UTF8.GetBytes(input);
            StringBuilder sb = new StringBuilder();
            using (MD5 md5Hash = MD5.Create())
            {
                byte[] hashBytes = md5Hash.ComputeHash(inputBytes);

                for (int i = 0; i < hashBytes.Length; i++)
                {
                    sb.Append(hashBytes[i].ToString("x2"));
                }

            }
            return sb.ToString();
        }
    }
}
